#include<stdio.h>
int main(){
	int time_h;
	int time_m;
	scanf("%d:%d",&time_h,&time_m);
	if(time_h>=12){
		if(time_h>12) time_h=time_h-12;
		printf("%d:%d PM",time_h,time_m);
	}
	else printf("%d:%d AM",time_h,time_m);
	return 0;
}
